<%@page import="java.util.List"%>
<%@page import="com.nithya.hms.Patient"%>
<%@page import="com.nithya.hms.Doctor"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hospital Management System</title>
</head>
<body>
	<%
		Patient patient = (Patient) session.getAttribute("patient");
	%>
	<table width="100%" border="1">
		<tr>
			<th><%=patient.getFirstName()%> <%=patient.getLastName()%></th>
			<th><a href="<%=request.getContextPath()%>/secure/logout.do">Logout</a></th>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<form action="patient-home.do" method="get">
					<table border="1">
						<tr>
							<th>Doctor Name:</th>
							<td><select name="doctorId">
									<%
										List<Doctor> list = (List<Doctor>) request.getAttribute("list");
										for (Doctor doc : list) {
									%>
									<option value="<%=doc.getId()%>"
									<%
										String selectedDocId = request.getParameter("doctorId");
										if(selectedDocId!=null && Integer.parseInt(selectedDocId) == doc.getId()){

								   %>
								   		selected="selected"
								   <%
										}
									%>
									><%=doc.getFirstName() + " " + doc.getLastName()%></option>
									<%
										}
									%>
							</select></td>
							<td><input type="submit" value="Get Available Appointment" /></td>
						</tr>
						<%
						
							List<Integer> times = (List<Integer>) request.getAttribute("times");
							if(times!=null){
						%>
						<tr>
							<th>Choose Time:</th>
							<td><select name="time">
									<%
										for (Integer time : times) {
									%>
									<option value="<%=time%>"><%=time%></option>
									<%
										}
									%>
							</select></td>
							<td><input type="submit" value="Get Appointment" /></td>
						</tr>
						<%
							}
						%>
					</table>
				</form>
			</td>
		</tr>
	</table>
</body>
</html>